home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 269 < prev    next >
Encoding:
Text File  |  1996-08-06  |  6.2 KB  |  124 lines

  1. Newsgroups: comp.lang.c,comp.std.c
  2. Path: blackbush.xlink.net!slsv6bt!slsv6bt!kanze
  3. From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
  4. Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
  5. In-Reply-To: tanmoy@qcd.lanl.gov's message of 30 Jan 1996 01:30:41 GMT
  6. Message-ID: <KANZE.96Feb1144952@slsvewt.lts.sel.alcatel.de>
  7. Sender: news@lts.sel.alcatel.de
  8. Organization: SEL
  9. References: <30C40F77.53B5@swsbbs.com> <SPENCER.96Jan22113215@zorgon.ERA.COM>
  10.     <KANZE.96Jan26164833@gabi.gabi-soft.fr> <DLtABq.Fzu@mv.mv.com>
  11.     <4edqh2$rvl@solutions.solon.com>
  12.     <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
  13.     <TANMOY.96Jan29090518@qcd.lanl.gov>
  14.     <KANZE.96Jan29201312@slsvewt.lts.sel.alcatel.de>
  15.     <TANMOY.96Jan29183041@qcd.lanl.gov>
  16. Date: 01 Feb 1996 13:49:52 GMT
  17.  
  18. In article <TANMOY.96Jan29183041@qcd.lanl.gov> tanmoy@qcd.lanl.gov
  19. (Tanmoy Bhattacharya) writes:
  20.  
  21. |> In article <KANZE.96Jan29201312@slsvewt.lts.sel.alcatel.de>
  22. |> kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes: 
  23. |> <snip>
  24. |>    I agree, but...
  25.  
  26. |>    Try naming a global function read, and see what happens (on most
  27. |>    compilers, anyway).  In fact, the Posix standard requires it, and
  28.  
  29. |> What should happen? It compiles perfectly and produces the expected
  30. |> answer! 
  31.  
  32.     [Example deleted...]
  33. |> (By the way, your assertion is correct: in general few compilers are
  34. |> completely conforming. My examples don't work if I change read to a
  35. |> write :-)
  36.  
  37. |>    thus, you cannot be Posix compliant without encroaching upon the user
  38. |>    name space.  (For example.  I'm sure that most other systems will have
  39. |>    similar constraints.)
  40.  
  41. |> This is incorrect. What the compiler has to do is to ensure that posix
  42. |> definitions are not seen unless I invoke undefined behaviour (e.g. by
  43. |> #including a posix specific header or leaving an external symbol
  44. |> undefined). Pretty easy to arrange usually (if the linker helps by not
  45. |> loading from the library something that has already been satisfied,
  46. |> for example, and no library routine calls a routine in user name
  47. |> space: if necessary they call a routine which is, separately, wrapped
  48. |> by a name in the user space): but old machines (like SunOS) have not
  49. |> yet done this.
  50.  
  51. In my posting, I wasn't so much talking about what can be done if the
  52. implementor wanted to do things correctly.  I was talking about the
  53. difference between what the standard says can be done, and what you
  54. can, in reality, do.  I know that the Posix people when to some care
  55. to make sure that what they demanded *was* compatible with the C
  56. standard.  The result is that fully conforming Posix implementations
  57. are as rare as fully conforming C compilers:-).
  58.  
  59. |>    |> For example, assuming that the concept of a far pointer is truly
  60. |>    |> required (It is really an exceptional circumstance which truly
  61. |>    |> _requires_ it; a compiler should usually figure out whether a near or
  62. |>    |> far pointer will work better: but that is a separate discussion), a
  63. |>    |> compiler should invent a keyword in the implementation name space
  64. |>    |> (e.g. __far) for it. It may provide a non-default switch
  65. |>    |> /backward-compatible to allow it to recognize far as a keyword and
  66. |>    |> treat it as a syntax error if used as a variable name.
  67.  
  68. |>    |> But I agree that discussions in comp.lang.c should also take care of
  69. |>    |> current realities, even if those realities are fossils of an era long
  70. |>    |> past, frozen in time only by the arrogant ignorance of a large body of
  71. |>    |> users with a narrow view to the future.
  72.  
  73. |>    Well, I'm not sure that I'd consider Posix a fossil of an era long
  74. |>    past, although it certainly reflects a long history.
  75.  
  76. |> As I said, almost no Posix extension requires diagnostic. It usually
  77. |> specifies meaning for constructs undefined in C.
  78.  
  79. The Posix extensions may not require it, but most of the Posix (or
  80. so-called Posix) implementations still have problems like the above
  81. (user defined global function named write, or ...).
  82.  
  83. |>    I'm not sure where to draw the line.  Discussions of `read' certainly
  84. |>    don't belong in c.l.c.  But simply telling someone that his system is
  85. |>    broken because printf stopped working when he declared a global read
  86. |>    is not going to help anyone, even if, strictly speaking, it is true
  87. |>    according to the standard.
  88.  
  89. |>    I may be oversensitivized to this problem.  My usual hang-outs are the
  90. |>    C++ groups.  Given the speed the C++ standard has evolved, there is no
  91. |>    such thing as a conforming compiler, and most people have to get their
  92. |>    programs working now, and not in 10 years time.  As a result, we do
  93. |>    spend a lot of time talking about compiler idiocyncracies.
  94.  
  95. |> As far as comp.lang.c is concerned, I would say that pointing out to
  96. |> people that their compiler is broken because it does not allow them an
  97. |> external function called write is good enough. It tells them:
  98. |>  1) The compiler should: they should complain to the vendor.
  99. |>  2) The temporary fix is to not name the function write.
  100.  
  101. |> Isn't that good enough?
  102.  
  103. If there were just one compiler where this was the case, yes.  Where
  104. in fact, it is a general problem on a large class of implementations,
  105. I would tend to say: `avoid naming a function write, even if it works
  106. on your implementation'.  A program which contains a user defined
  107. global function named write may be conforming (according to the
  108. standard), but it isn't portable (as things stand in real life).
  109.  
  110. This is, of course, in addition to your point 1.  If the compiler is
  111. not conforming on this question, they definitly should complain to the
  112. vendor.  If nobody complains, it is hardly likely that the vendor will
  113. try and fix it.  (At one time, I had a small collection of just such
  114. conforming programs, which I made a point of trying out on every new
  115. compiler, and complaining when they didn't work:-).  I dropped it when
  116. I started working with C++; my real applications generated enough
  117. error reports without trying to be intentionally difficult.)
  118. --
  119. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  120. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  121. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  122.                 -- A la recherche d'une activitΘ dans une region francophone
  123.  
  124.